package com.atguigu.knife4j.controller;

import com.atguigu.knife4j.pojo.User;
import com.atguigu.knife4j.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@Tag(name = "用户信息管理")
public class UserController {

    @Resource
    private UserService userService ;

    @GetMapping("/list")
    @Operation(summary = "用户列表")
    public List<User> list(){
        return userService.getUserList();
    }

    @PostMapping("/")
    @Operation(summary = "保存用户")
    public void save(@Parameter(description="用户请求体参数") @RequestBody User user){
        userService.addUser(user);
    }

    @GetMapping("/{uid}")
    @Operation(summary = "根据id查询用户")
    public User edit(@Parameter(description="用户id") @PathVariable String uid){
        return userService.getById(uid);
    }

}
